// 
import express from 'express';
import multer from 'multer';
import bodyParser from 'body-parser';
const app = express();
// 使用中间件解析 JSON 和 URL 编码的表单数据
// app.use(express.json()); // 用于解析 application/json
// app.use(express.urlencoded({ extended: false })); // 用于解析 application/x-www-form-urlencoded

app.use('*', (req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
    next();
})
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.post('/tinypng', async (req, res) => {
    console.log('req:=============',req.body);
    res.json({
        msg: 'Hello World',
    });
});

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});
